    //
//  VuePrincipale.m
//  iGuy
//
//  Created by Victor Carmouze on 16/11/10.
//  Copyright 2010 EPITA. All rights reserved.
//

#import "VuePrincipale.h"


@implementation VuePrincipale

@synthesize happy,sad,afraid;
@synthesize scrollView;

 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
		[self initTableaux];
		id fichierAudioHappy = [[NSBundle mainBundle] pathForResource:[tableauNomSons objectAtIndex:0] ofType:@"m4v"];
		id fichierAudioSad = [[NSBundle mainBundle] pathForResource:[tableauNomSons objectAtIndex:1] ofType:@"m4v"];
		id fichierAudioAfraid = [[NSBundle mainBundle] pathForResource:[tableauNomSons objectAtIndex:2] ofType:@"m4v"];
		CFURLRef cheminAccesHappy = (CFURLRef)[[NSURL alloc] initFileURLWithPath:fichierAudioHappy];
		CFURLRef cheminAccesSad = (CFURLRef)[[NSURL alloc] initFileURLWithPath:fichierAudioSad];
		CFURLRef cheminAccesAfraid = (CFURLRef)[[NSURL alloc] initFileURLWithPath:fichierAudioAfraid];
		AudioServicesCreateSystemSoundID (cheminAccesHappy,&soundHappy);
		AudioServicesCreateSystemSoundID (cheminAccesSad,&soundSad);
		AudioServicesCreateSystemSoundID (cheminAccesAfraid,&soundAfraid);
	
    }
    return self;
}


/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/

-(IBAction)boutonHappy:(id)sender{
	AudioServicesPlaySystemSound(soundHappy);
}

-(IBAction)boutonSad:(id)sender{
	AudioServicesPlaySystemSound(soundSad);
}

-(IBAction)boutonAfraid:(id)sender{
	AudioServicesPlaySystemSound(soundAfraid);
}

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
	scrollView.contentSize = CGSizeMake(0, 455);
	scrollView.maximumZoomScale = 4.0;
	scrollView.minimumZoomScale = 0.75;
	scrollView.clipsToBounds = YES;
	scrollView.delegate = self;
}

-(void)initTableaux {
	tableauNomSons = [NSArray arrayWithObjects:@"fichierAudioHappy",@"fichierAudioSad",@"fichierAudioAfraid",nil];
}
/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
	[afraid release];
	[sad release];
	[happy release];
	[scrollView release];
    [super dealloc];
}


@end
